// packageD/newPage/treasury/treasury.js
var t = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    items: [null, null, null, null, null],
    CustomBar: 0,
    tabsList: ["亲密好友", "普通好友"],
    currentTabs: 0,
    type: 1,//1亲密好友 2普通好友
    money: 0,//当前账户 钱
    all_yeji: 0,//总业绩
    totalNum: 0,//总人数
    userList: [],
    loginshow: !1,
    firstshow: !1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.firstlogin();
    this.getSysInfo();
    // this.getListData();

  },
  firstlogin: function() {
    var t = !1;
    try {
        wx.getStorageSync("wx_token") ? (this.setData({
            loginshow: !1
        }), t = !1,this.getListData()) : (this.setData({
            loginshow: !0
        }), t = !0);
    } catch (e) {
        this.setData({
            loginshow: !0
        }), t = !0;
    }
    return t;
},
  getSysInfo() {
    var _this = this;
    // 获取设备信息
    wx.getSystemInfo({
      success: res => {
        let menuButtonInfo = {}
        if (res.platform === 'ios') {
          // ios设备的胶囊按钮都是固定的
          menuButtonInfo = {
            width: 87,
            height: 32,
            left: res.screenWidth - 7 - 87,
            right: res.screenWidth - 7,
            top: res.statusBarHeight + 4,
            bottom: res.statusBarHeight + 4 + 32
          }
        } else {
          // 安卓通过api获取
          menuButtonInfo = wx.getMenuButtonBoundingClientRect()
        }
        // 导航栏高度 = 状态栏到胶囊的间距（胶囊距上未知-状态栏高度）* 2 + 胶囊高度 + 状态栏高度
        let navHeight = (menuButtonInfo.top - res.statusBarHeight) * 2 + menuButtonInfo.height + res.statusBarHeight;
        console.log('navHeight:', navHeight);
        _this.setData({
          CustomBar: navHeight + 60
        })
        // 按钮上下边距高度
       let menuBottom = menuButtonInfo.top - res.statusBarHeight;
        // 导航栏右边到屏幕边缘的距离
        let menuRight = res.screenWidth - menuButtonInfo.right;
        // 导航栏高度
        let menuHeight = menuButtonInfo.height;
      },
      fail(err) {}
    })
  },
  gotologin: function() {
    wx.navigateTo({
        url: "/pages/login/login"
    });
},
  changeTabs(e) {
    let index = e.currentTarget.dataset.index
    this.setData({
      currentTabs: index,
      type: index + 1
    })
    this.getListData()
  },
  getListData: function() {
    var a = this;
    var o = t.getNetAddresss("TuWenhua.order_price");
    t._postNetWork({
        url: o,
        data: {
          uid: wx.getStorageSync('yz_uid'),
          type: this.data.type
        },
        success: function(i) {
            var o = i.data;
            if (1 != o.result) return t.tips(o.msg);
            a.setData({
              money: o.data.money,//当前账户 钱
              all_yeji: o.data.all_yeji,//总业绩
              totalNum: o.data.num,//总人数
              userList: o.data.user,
              firstshow: !0
            });
        }
    });
},
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})